<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>class类继承1</title>
</head>

<body>
  <script>
    // 手机
    function Phone(brand, price) {
      this.brand = brand;
      this.price = price;
    }

    Phone.prototype.call = function() {
      console.log("我可以改变世界")
    }

    // 智能手机
    function smartMobile(brand, price, color, size) {
      Phone.call(this, brand, price);
      this.color = color;
      this.size = size;
    }

    // 设置子级构造函数的原型
    smartMobile.prototype = new Phone();
    smartMobile.prototype.constructor = smartMobile;

    // 声明子类的方法
    smartMobile.prototype.phone = function() {
      console.log("我可以拍照");
    }

    smartMobile.prototype.play = function() {
      console.log("我可以玩游戏");
    }

    let chuizi = new smartMobile("锤子", 5999, "银白色", "6.4inch");
    console.log(chuizi)
  </script>
</body>

</html>